<template>
    <div class="book-view-header">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="书名">
                <el-input v-model="formInline.user" placeholder="请输入书名" clearable />
            </el-form-item>
            <el-form-item label="书籍分类">
                <el-select v-model="formInline.region" placeholder="全部" clearable>
                    <el-option label="玄幻小说" value="玄幻小说" />
                    <el-option label="教辅资料" value="教辅资料" />
                    <el-option label="全部" value="全部" />
                </el-select>
            </el-form-item>
            <el-form-item label="出版日期">
                <el-date-picker v-model="formInline.date" type="date" placeholder="请选择日期" clearable />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">搜索</el-button>
                <el-button type="primary" @click="onSubmit">添加</el-button>
            </el-form-item>
        </el-form>
    </div>

    <div class="book-view-body">
        <el-table :data="tableData" style="width: 100%">
            <el-table-column fixed prop="id" label="书籍id" width="150" />
            <el-table-column prop="name" label="书名" width="120" />
            <el-table-column prop="auther" label="作者" width="120" />
            <el-table-column prop="publisher" label="出版社" width="120" />
            <el-table-column prop="isbn" label="isbn" width="100" />
            <el-table-column prop="publishDate" label="出版日期" width="120" />
            <el-table-column prop="price" label="书籍价格" width="120" />
            <el-table-column prop="storage" label="书籍库存" width="120" />
            <el-table-column prop="isDelete" label="是否可用" width="120">
                <template #default="item">
                    <el-tag v-if="item.row.isDeleted === 1" type="success">可用</el-tag>
                    <el-tag v-else type="danger">不可用</el-tag>
                </template>
            </el-table-column>

            <el-table-column fixed="right" label="操作" min-width="120">

                <template #default>
                    <el-button link type="primary" size="small" @click="handleClick">
                        编辑
                    </el-button>
                    <el-button link type="danger" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>

    <!-- 分页 -->
    <div class="book-view-footer">
        <el-pagination size="small" background layout="prev, pager, next" :total="50" class="mt-4" />
    </div>

</template>

<script setup>
import { id } from 'element-plus/es/locales.mjs'
import { isDeleteExpression } from 'typescript'
import { reactive } from 'vue'

const formInline = reactive({
    user: '',
    region: '',
    date: '',
})

const onSubmit = () => {
    console.log('submit!')
}


const handleClick = () => {
    console.log('click')
}

const tableData = [
    {
        id: 1,
        name: 'John Brown',
        auther: 'Jim Green',
        publisher: 'New York No. 1 Lake Park',
        isbn: '123456789',
        publishDate: '2016-05-02',
        price: '100',
        storage: '100',
        isDeleted: 1,
    },
    {
        id: 2,
        name: 'John Brown',
        auther: 'Jim Green',
        publisher: 'New York No. 1 Lake Park',
        isbn: '123456789',
        publishDate: '2016-05-02',
        price: '100',
        storage: '100',
        isDeleted: 0,
    },
    {
        id: 3,
        name: 'John Brown',
        auther: 'Jim Green',
        publisher: 'New York No. 1 Lake Park',
        isbn: '123456789',
        publishDate: '2016-05-02',
        price: '100',
        storage: '100',
        isDeleted: 1,
    },
    {
        id: 4,
        name: 'John Brown',
        auther: 'Jim Green',
        publisher: 'New York No. 1 Lake Park',
        isbn: '123456789',
        publishDate: '2016-05-02',
        price: '100',
        storage: '100',
        isDeleted: 0,
    },
    {
        id: 5,
        name: 'John Brown',
        auther: 'Jim Green',
        publisher: 'New York No. 1 Lake Park',
        isbn: '123456789',
        publishDate: '2016-05-02',
        price: '100',
        storage: '100',
        isDeleted: 2,
    },


]
</script>

<style scoped>
.demo-form-inline .el-input {
    --el-input-width: 220px;
}

.demo-form-inline .el-select {
    --el-select-width: 220px;
}
</style>